<?php namespace App\Controllers;

use CodeIgniter\Controller;
use  \App\Models\Setupmodel;



class Setup  extends BaseController
{

protected $userName;
protected $password;
protected $role;
 protected $myTime;

				 public function __construct() 
				    {
						parent::__construct();
						$this->myTime = parent::getTime();
						
						$this->myDate= date("d/m/Y",$this->myTime); 	
					
			       }










	public function setUpForm()

	{
	  



	  $data =[
			'title'=>'admin set up',
			'date'=>$this->myDate
			];
				
		
			echo view('setUpAdmin',$data);
			

	}


      public function process()
      
      {
   $this->userName=   $this->request->getVar('name'); 
   
   $pass=  $this->request->getVar('password'); 
   $this->password =    password_hash($pass,PASSWORD_DEFAULT);
   $this->role= $this->request->getVar('list'); 
  
  
  
  
   
   $handle= new Setupmodel();
      $handle->adminUser($this->userName,$this->password,$this->role);
      echo "done  , now go to url /blackcat to login ";
      
      /*  please note the way its set up you can only have one admin user because db select gets first entry,si wont see anything else   */
      
      }
      


}
